<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html>
<head>
  <base href="${path}/pages/">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <title>${movie.movieName}影评</title>
  <link rel="stylesheet" type="text/css" href="../layui/css/layui.css">
  
  <link rel="stylesheet" href="../layui/css/layui.css" media="all">
<!--加载meta IE兼容文件-->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>

<ul class="layui-nav" lay-filter="">
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon">&#xe68e;</i></a></li>
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon layui-icon-fire"></i> 影评天下</a></li>
  <li class="layui-nav-item" style="float:right" >
  	<a href="${path}/pages/register.jsp" id="register">注册</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
    <a href="${path}/pages/login.jsp" id="login">登录</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
  <a href="${path}/action/user/userCenter" id="user_center"></a>
  <dl class="layui-nav-child"> <!-- 二级菜单 -->
      <dd><a href="${path}/action/user/logout">登出</a></dd>
   </dl>
  </li>
  <li> <input type="hidden" value="${user.flag }" id="flag"></li>
</ul>


<hr class="layui-bg-gray">

	<div class="layui-form" style="margin-top: 10px;margin-right:110px">
		<input type="hidden" name="movieId" value="${movie.id}">
		<input type="hidden" name="writerId" value="${user.id}">
  		<div class="layui-form-item">
    		<div class="layui-input-block">
      			<input type="text" name="title"  required placeholder="请输入标题" autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		
  		
  <div class="ll j a_stars" onmouseover="rate(this,event)" style="margin-left:110px;margin-bottom: 20px">
            
    
   	评价:
    <span id="rating"> <span id="stars" data-solid="../img/star_onmouseover.png" data-hollow="../img/star_hollow_hover.png" data-solid-2x="./img/star_onmouseover@2x.png" data-hollow-2x="../img/star_hollow_hover@2x .png">

                    <a href="javascript:;" class="j a_collect_btn" name="pbtn-26985127-collect-1">
        <img src="../img/star_hollow_hover.png" id="star1" width="16" height="16"></a>
                    <a href="javascript:;" class="j a_collect_btn" name="pbtn-26985127-collect-2">
        <img src="../img/star_hollow_hover.png" id="star2" width="16" height="16"></a>
                    <a href="javascript:;" class="j a_collect_btn" name="pbtn-26985127-collect-3">
        <img src="../img/star_hollow_hover.png" id="star3" width="16" height="16"></a>
                    <a href="javascript:;" class="j a_collect_btn" name="pbtn-26985127-collect-4">
        <img src="../img/star_hollow_hover.png" id="star4" width="16" height="16"></a>
                    <a href="javascript:;" class="j a_collect_btn" name="pbtn-26985127-collect-5">
        <img src="../img/star_hollow_hover.png" id="star5" width="16" height="16"></a>
    	</span><span id="rateword" class="pl"></span>
    	<input id="n_rating" type="hidden" name="rating" value="" autocomplete="off" class="layui-input">
    </span>

</div>
     			
  		<div class="layui-form-item layui-form-text">
    		<div class="layui-input-block">
      			<textarea name="content" id="content" style="display:none;" required placeholder="请输入内容" class="layui-textarea">${review.content}</textarea>
    		</div>
  		</div>
	    <div class="layui-form-item">
    		<div class="layui-input-block">
      			<button class="layui-btn" lay-submit lay-filter="formDemo"> 确定 </button>
      			<button class="layui-btn" onclick="javascript:history.back(-1);"> 取消  </button>
    		</div>
  		</div>
  	</div>
 
 
<script type="text/javascript" src="../js/jquery-1.7.min.js"></script>
<script type="text/javascript">
function rate(obj, oEvent) {
	// 图片地址设置
	var imgSrc = '../img/star_hollow_hover.png';
	var imgSrc_2 = '../img/star_onmouseover.png';
	if(obj.rateFlag) return;
	var e = oEvent || window.event;
	var target = e.target || e.srcElement;
	var imgArray = obj.getElementsByTagName("img");
	for(var i = 0; i < imgArray.length; i++) {
		imgArray[i]._num = i;
		imgArray[i].onclick = function() {
			if(obj.rateFlag) return;
			//obj.rateFlag = true;
			$('#n_rating').val(this._num+1);
			if(target.tagName == "IMG") {
				for(var j = 0; j < imgArray.length; j++) {
					if(j <= target._num) {
						imgArray[j].src = imgSrc_2;
					} else {
						imgArray[j].src = imgSrc;
					}
				}
			} else {
				for(var k = 0; k < imgArray.length; k++) {
					imgArray[k].src = imgSrc;
				}
			}
			switch(this._num+1)
			{
			    case (1) : $('#rateword').html("很差"); break;

				case (2) : $('#rateword').html("较差"); break;

			 	case (3) : $('#rateword').html("还行"); break;
			 	 
			 	case (4) : $('#rateword').html("推荐"); break;
			 	 
			 	case (5) : $('#rateword').html("力荐"); break;

				default : $('#rateword').html("极差");
			}
		};
	}
}
	
</script>
  
<script type="text/javascript" src="../layui/layui.js"></script>
<script>
//Demo
/*  name=
   用户名:UName
   密码:Pd
   重新输入的密码:RePd
   手机号:PhoneNb
   邮箱号:Email
 */
 layui.use(['form', 'laydate', 'layedit','element'], function(){
		var form = layui.form;
		var $ = layui.$;
		var laydate=layui.laydate;
		var layedit = layui.layedit;
		var element=layui.element;
		
		var flag=$('#flag').val();
      	var success=(flag=="");
      	if(success!=true){
              	 $("#user_center").html("个人中心");
              	 $("#login").html("");
              	 $("#register").html("");

          	}else{
          		$("#user_center").html("");
          	 	$("#login").html("登录");
          	 	$("#register").html("注册");
          	}
		
		//富文本框
		layedit.set({
  			uploadImage: {url: '${path}/api/upload'}
		});
		var editIdx = layedit.build('content');
  
  
  
  		//监听提交
		form.on('submit(formDemo)', function(data) {
		
		// 将富文本框中的内容，赋值给content文本域
		data.field.content = layedit.getContent(editIdx);
		
		$.post('${path}/action/review/save', data.field, function(json) {
				
				//alert('${ movie.id }');
				//debugger
				window.location.href = '${path}/action/movie/movieInfo?id=${ movie.id }';
			}, 'JSON');
	});
  

  

});
</script>




</body>
</html>